import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';

class ReqGroup {
  final Dio _dio;

  ReqGroup(this._dio);

  //上传图片
  upload({
    @required file,
  }) {
    return _dio.post('/user/upload', data: file);
  }

  //创建小组
  create({
    @required Map<String, String> formdata,
  }) {
    return _dio.post('/group/create', data: formdata);
  }

  //小组列表
  grouplist() {
    return _dio.get('/group/list');
  }

  //小组列表
  apply({
    @required String groupId,
  }) {
    return _dio.post('/group/apply', data: {"group_id": groupId});
  }

  //我的小组
  groupMy() {
    return _dio.get('/group/my');
  }

   //我的小组
  managers() {
    return _dio.get('/group/managers');
  }

  //申请列表
  applyList({
    String groupId,
  }) {
    return _dio
        .get('/group/apply_list', queryParameters: {"group_id": groupId});
  }

  // 通过申请
  approveApply({
    @required String groupId,
    @required String applierId,
  }) {
    return _dio.post('/group/approve_apply',
        data: {"group_id": groupId, "applier_id": applierId});
  }

  // 拒绝申请
  rejectApply({
    @required String groupId,
    @required String applierId,
  }) {
    return _dio.post('/group/reject_apply',
        data: {"group_id": groupId, "applier_id": applierId});
  }

  // 批量设置好管理员
  setAdmin({
    @required String groupId,
    @required List<String> applierIds,
  }) {
    return _dio.post('/group/set_admin',
        data: {"group_id": groupId, "applierIds": applierIds});
  }

  // 成员列表
  members({
    @required String groupId,
  }) {
    print(groupId);
    return _dio.get('/group/managers', queryParameters: {"group_id": groupId});
  }

  // 小组通知列表
  loadGroupMessage() {
    return _dio.get('/message/group', queryParameters: {});
  }

  // 发布动态
  momentPublish({
    @required String content,
    @required List<String> pictures,
  }) {
    return _dio
        .post('/moment/publish', data: {"pictures": pictures, "content": content});
  }
}
